﻿@{
    ViewBag.Title = "产品编辑";
    var product = ViewBag.Product as CubicFWNet.Data.Models.Product;
}

<section class="content-header">
    <h1>
        产品编辑
    </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i>@Resources.Global.PageTitle</a></li>
        <li><a href="@Url.Action("Index","Home")">首页</a></li>
        <li class="active">产品编辑</li>
    </ol>
</section>

<section class="content">
    <form class="form-horizontal" method="post" id="formMain">
        <div class="box box-solid">
            <div class="box-body">
                <div class="row">
                    <input type="hidden" name="ProductID" value="@product.Id" />
                    <input type="hidden" id="modalData" value="@product.Data">
                    <input type="hidden" id="Data" name="Data" />
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="ProductName" class="col-sm-3 control-label">产品名称</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="ProductName" name="ProductName" value="@product.Name" maxlength="200">
                        </div>
                    </div>
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Number" class="col-sm-3 control-label">产品编号</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="Number" name="Number" value="@product.Number" maxlength="50">
                        </div>
                    </div>
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="WorkType" class="col-sm-3 control-label">加工方式</label>
                        <div class="col-sm-9">
                            <select class="form-control" id="WorkType" name="WorkType">
                                @if (product.WorkType == 1)
                                {
                                    <option value="1" selected="selected">模切</option>
                                    <option value="2">切卷</option>
                                }
                                else if (product.WorkType == 2)
                                {
                                    <option value="1">模切</option>
                                    <option value="2" selected="selected">切卷</option>
                                }
                            </select>
                        </div>
                    </div>
                    <div class="form-group col-md-6 col-sm-12" style="display:none">
                        <label for="Format" class="col-sm-3 control-label">产品规格</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="Format" name="Format" value="@product.Format" />
                        </div>
                    </div>
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Pack" class="col-sm-3 control-label">包装单位</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="Pack" name="Pack" value="@product.Pack" maxlength="50" />
                        </div>
                    </div>
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Unit" class="col-sm-3 control-label">基本单位</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="Unit" name="Unit" value="@product.Unit" maxlength="50" />
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="PackRequire" class="col-sm-3 control-label">包装要求</label>
                        <div class="col-sm-9">
                            <select class="form-control" id="PackRequire" name="PackRequire">
                                @if (product.PackRequire == 1)
                                {
                                    <option value="1" selected>平张</option>
                                    <option value="2">卷筒</option>
                                }
                                else if (product.PackRequire == 2)
                                {
                                    <option value="1">平张</option>
                                    <option value="2" selected>卷筒</option>
                                }
                            </select>
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="PackAmount" class="col-sm-3 control-label">包装数量</label>
                        <div class="col-sm-9">
                            <input type="number" class="form-control" id="PackAmount" name="PackAmount" value="@product.PackAmount" maxlength="20" />
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Width" class="col-sm-3 control-label">宽度-mm</label>
                        <div class="col-sm-9">
                            <input type="number" class="form-control" id="Width" name="Width" value="@product.SizeWidth" maxlength="20" />
                        </div>
                    </div>
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Length" class="col-sm-3 control-label">长度-mm</label>
                        <div class="col-sm-9">
                            <input type="number" class="form-control" id="Length" name="Length" value="@product.SizeLenth" maxlength="20" />
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Price" class="col-sm-3 control-label">内部价格</label>
                        <div class="col-sm-9">
                            <input type="number" class="form-control" id="Price" name="Price" value="@product.Price" maxlength="20" />
                        </div>
                    </div>

                    <div id="json-content">
                        <div class="form-group col-md-6 col-sm-12" style="display:none">
                            <label for="Quantity" class="col-sm-3 control-label">起订量[PCS]</label>
                            <div class="col-sm-9">
                                <input type="number" class="form-control" id="Quantity" name="Quantity" data-des="起订量[PCS]" value="@product.Quantity" maxlength="20" />
                            </div>
                        </div>
                        <div class="form-group col-md-6 col-sm-12">
                            <label for="Color" class="col-sm-3 control-label">颜色</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="Color" name="Color" data-des="颜色" maxlength="50" value="@product.Color" />
                            </div>
                        </div>
                        <div class="form-group col-md-6 col-sm-12">
                            <label for="Angel" class="col-sm-3 control-label">角度</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="Angel" name="Angel" data-des="角度" value="@product.Angel" maxlength="50" />
                            </div>
                        </div>
                        <div class="form-group col-md-6 col-sm-12">
                            <label for="Tolerance" class="col-sm-3 control-label">正公差-mm</label>
                            <div class="col-sm-9">
                                <input type="number" class="form-control" id="Tolerance" name="Tolerance" data-des="公差-mm" value="@product.Tolerance" maxlength="20" />
                            </div>
                        </div>
                        <div class="form-group col-md-6 col-sm-12">
                            <label for="ToleranceMinus" class="col-sm-3 control-label">负公差-mm</label>
                            <div class="col-sm-9">
                                <input type="number" class="form-control" id="ToleranceMinus" name="ToleranceMinus" data-des="公差-mm" value="@product.ToleranceMinus" maxlength="20" />
                            </div>
                        </div>
                        <div class="form-group col-md-6 col-sm-12">
                            <label for="Space" class="col-sm-3 control-label">左右间距-mm</label>
                            <div class="col-sm-9">
                                <input type="number" class="form-control" id="Space" name="Space" data-des="左右间距-mm" value="@product.Space" maxlength="20" />
                            </div>
                        </div>
                        <div class="form-group col-md-6 col-sm-12">
                            <label for="Margin" class="col-sm-3 control-label">左右边距-mm</label>
                            <div class="col-sm-9">
                                <input type="number" class="form-control" id="Margin" name="Margin" data-des="左右边距-mm" value="@product.Margin" maxlength="20" />
                            </div>
                        </div>
                        <div class="form-group col-md-6 col-sm-12">
                            <label for="Distance" class="col-sm-3 control-label">跳距-mm</label>
                            <div class="col-sm-9">
                                <input type="number" class="form-control" id="Distance" name="Distance" data-des="跳距-mm" value="@product.Distance" maxlength="20" />
                            </div>
                        </div>
                    </div>


                </div>

                @*<div class="row">
                        <div class="form-group col-md-6 col-sm-12">
                            <label class="col-sm-3 control-label">状态</label>
                            <div class="col-sm-9">
                                <span class="form-control" style="border:none">
                                    @if (product.Status == 1)
                                    {
                                        <input type="radio" id="rbStatus1" name="Status" value="1" checked />
                                        <label for="rbStatus1">正常</label>
                                        <input type="radio" id="rbStatus2" name="Status" value="-1" style="margin-left:10px" />
                                        <label for="rbStatus2">禁用</label>

                                    }
                                    else
                                    {
                                        <input type="radio" id="rbStatus1" name="Status" value="1" />
                                        <label for="rbStatus1">正常</label>
                                        <input type="radio" id="rbStatus2" name="Status" value="-1" checked style="margin-left:10px" />
                                        <label for="rbStatus2">禁用</label>

                                    }

                                </span>
                            </div>
                        </div>
                    </div>*@

                <div class="row">
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Explain" class="col-sm-3 control-label">产品特点</label>
                        <div class="col-sm-9">
                            <textarea rows="3" class="form-control" id="Explain" name="Explain" maxlength="500">@product.Explain</textarea>
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Memo" class="col-sm-3 control-label">备注</label>
                        <div class="col-sm-9">
                            <textarea rows="3" class="form-control" id="Memo" name="Memo" maxlength="500">@product.Memo</textarea>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Creator" class="col-sm-3 control-label">创建人</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="Creator" name="RealName" value="@product.CreatorName" readonly="readonly" />
                        </div>
                    </div>
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="CreateTime" class="col-sm-3 control-label">创建时间</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="CreateTime" value="@product.CreateTime" readonly="readonly" />
                        </div>
                    </div>
                </div>

            </div>
            <div class="box-footer">
                <div class="box-footer">
                    <span class="btn btn-primary" onclick="FormSub()" id="btnOk">确 定</span>&nbsp;&nbsp;&nbsp;&nbsp;
                    <a class="btn btn-primary" href="@Url.Action("Index","Product")">返 回</a>
                </div>
            </div>
        </div>
    </form>
</section>

@section Scripts {
    <script type="text/javascript">
        //提交表单
        function FormSub() {
            var name = $("#ProductName").val().trim();
            if (name == "") {
                $.modalAlert("请输入产品名称", "warning");
                return false;
            }

            var number = $("#Number").val().trim();
            if (number == "") {
                $.modalAlert("请输入产品编号", "warning");
                return false;
            }

            var width = $("#Width").val().trim();
            if (width == "") {
                $.modalAlert("请输入产品宽度", "warning");
                return false;
            }

            var length = $("#Length").val().trim();
            if (length == "") {
                $.modalAlert("请输入产品长度", "warning");
                return false;
            }

            var price = $("#Price").val().trim();
            if (price == "") {
                $.modalAlert("请输入产品内部价格", "warning");
                return false;
            }

            var qua = $("#Quantity").val().trim();
            if (qua == "") {
                $.modalAlert("请输入产品起订量", "warning");
                return false;
            }

            var tolerance = $("#Tolerance").val().trim();
            if (tolerance == "") {
                $.modalAlert("请输入正公差", "warning");
                return false;
            }

            var toleranceMinus = $("#ToleranceMinus").val().trim();
            if (toleranceMinus == "") {
                $.modalAlert("请输入负公差", "warning");
                return false;
            }

            var space = $("#Space").val().trim();
            if (space == "") {
                $.modalAlert("请输入左右间距", "warning");
                return false;
            }

            var margin = $("#Margin").val().trim();
            if (margin == "") {
                $.modalAlert("请输入左右边距", "warning");
                return false;
            }

            var sistance = $("#Distance").val().trim();
            if (sistance == "") {
                $.modalAlert("请输入跳距", "warning");
                return false;
            }

            $("#btnOk").attr('disabled', "true")
            $("#formMain").submit();
        }
    </script>
}